local MagicKeyDataHelper = {}

function MagicKeyDataHelper.getMagicKeyAttr(unit)
    local magickey_lvup = require("config.magickey_lvup")
    local level = unit:getLevel()
    local config = unit:getConfig()
    local lvId = config.lvId
    local result = {}
    for i = 1, level do
        local lvCfg = magickey_lvup.get(lvId, i)
        local attrId = lvCfg.attr_id
        local attaValue = lvCfg.attr_value
        if not result[attrId] then
            result[attrId] = 0
        end
        result[attrId] = result[attrId] + attaValue
    end
    return result
end

function MagicKeyDataHelper.getMagicKeyUpCost(unit)
    local magickey_lvup = require("config.magickey_lvup")
    local level = unit:getLevel()
    local config = unit:getConfig()
    local max = config.lv_max
    local nextlevel = level + 1
    if nextlevel > max then
        nextlevel = max
    end
    local lvId = config.lvId
    local costCfh = magickey_lvup.get(lvId, nextlevel)
    return costCfh
end

function MagicKeyDataHelper.getMagicEffect(magicUnit, result)
    local config = magicUnit:getConfig()
    if config.effectId > 0 then
        table.insert(result, config.effectId)
    end
    return result
end

return MagicKeyDataHelper
